﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebMvc_Survey.Attributes
{
    public class LoginAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //ring str = filterContext.RouteData.Values["id"].ToString();
            if (filterContext.HttpContext.Request.Cookies["UserId"] == null)
            {
                filterContext.Result = new RedirectResult("/Login");
            }

            base.OnActionExecuting(filterContext);
        }
    }
}
